package com.xiaolin.springbootdemo.controller;

import com.github.pagehelper.Page;
import com.xiaolin.springbootdemo.dto.PpDocumentQueryParam;
import com.xiaolin.springbootdemo.exception.ExceptionUtils;
import com.xiaolin.springbootdemo.model.PpDocument;
import com.xiaolin.springbootdemo.service.PpDocumentService;
import com.xiaolin.springbootdemo.utils.PageUtils;
import com.xiaolin.springbootdemo.utils.ResponseResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @ClassName PpDocumentController
 * @Description 描述
 * @Detail detail
 * @Author MyPC
 * @Date 2021/1/10
 * @Version 1.0
 */
@RestController
@RequestMapping("/PpDocument")
public class PpDocumentController {
    private static final Logger LOGGER= LoggerFactory.getLogger(PpDocumentController.class);
    @Autowired
    private PpDocumentService ppDocumentService;

    /**
     * 查询列表
     * @param param
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/list")
    public ResponseResult<PageUtils<PpDocument>> queryList(@Valid PpDocumentQueryParam param,
                                                      @RequestParam(name = "pageNum",defaultValue = "1") Integer pageNum,
                                                      @RequestParam(name = "pageSize",defaultValue = "10")Integer pageSize){
        List<PpDocument> ppDocuments = ppDocumentService.queryList(param, pageNum, pageSize);
        LOGGER.info("查询到了记录");
        return ResponseResult.success(PageUtils.getPageObj(ppDocuments));
    }
}
